package com.cardbaobao.cardbabyclient.ui.activity;

import android.os.Bundle;
import android.view.View;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.buried.Google;
import com.cardbaobao.cardbabyclient.buried.Self;
import com.cardbaobao.cardbabyclient.buried.SelfUtils;
import com.cardbaobao.cardbabyclient.ui.activity.base.BaseActivity;
import com.cardbaobao.cardbabyclient.buried.GoogleAnalyticsUtil;
import com.cardbaobao.cardbabyclient.widget.TitleBar;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Jiangzx on 13:56.
 * 社保、公积金查询失败页面
 */
public class InquiriesFailureActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    TitleBar titleBar;

    private String channelType;

    @Override
    protected void onResume() {
        super.onResume();
        if(InquiriesActivity.CHANNEL_GJJ.equals(channelType)){
            GoogleAnalyticsUtil.setScreenName(Google.ACCUM_FUND_QUERY_FAI);
        }else {
            GoogleAnalyticsUtil.setScreenName(Google.SOCIAL_QUERY_FAI);
        }

    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        titleBar.setLeftViewOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        channelType=getIntent().getStringExtra("channel_type");
        if(savedInstanceState!=null){
            channelType=savedInstanceState.getString("channel_type");
        }
        if("GJJ".equals(channelType)){
            //公积金
            mCurrentPageId= Self.Page.app_provident_fund_inquiry_failure_page;
            titleBar.setTitleText("公积金查询");
        }else{
            //社保
            mCurrentPageId= Self.Page.app_social_security_inquiry_failure_page;
            titleBar.setTitleText("社保查询");
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_inquries_failure;
    }

    @OnClick(R.id.bt_re_query)
    public void onClick(View view){
        switch (view.getId()){
            case R.id.bt_re_query:
                if(InquiriesActivity.CHANNEL_GJJ.equals(channelType)){
                    //公积金重新查询
                    SelfUtils.buriedClickData(Self.Action.app_click_provident_fund_re_inquiry,
                            Self.Action.app_click_provident_fund_re_inquiry_des,
                            mEnterPageTime,
                            mCurrentPageId,
                            mPrePageId);
                }else if(InquiriesActivity.CHANNEL_SHE_BAO.equals(channelType)){
                    //社保重新查询
                    SelfUtils.buriedClickData(Self.Action.app_click_social_security_re_inquiry,
                            Self.Action.app_click_social_security_re_inquiry_des,
                            mEnterPageTime,
                            mCurrentPageId,
                            mPrePageId);
                }
                initIntent();
                mIntent.setClass(mContext,InquiriesActivity.class);
                mIntent.putExtra("channel_type",channelType);
                startActivity(mIntent);
                finish();
                break;
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putString("channel_type",channelType);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        channelType=savedInstanceState.getString("channel_type");
    }
}
